package com.ysyc.driver_ee.factory;

import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.jcodecraeer.xrecyclerview.ProgressStyle;
import com.jcodecraeer.xrecyclerview.XRecyclerView;
import com.ysyc.driver_ee.tools.ScreenUtils;
import com.ysyc.driver_ee.tools.SpaceItemDecoration;


public class RecyclerViewFactory {


    public static void initVerticalRvDecoration(Context context, RecyclerView recyclerView, int spacing) {
        recyclerView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
        SpaceItemDecoration decoration = new SpaceItemDecoration(ScreenUtils.dip2px(context,spacing));
        recyclerView.addItemDecoration(decoration);

    }

    public static void initHorizontalRvDecoration(Context context, RecyclerView recyclerView, int spacing) {
        recyclerView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false));
        SpaceItemDecoration decoration = new SpaceItemDecoration(spacing);
        recyclerView.addItemDecoration(decoration);
    }

    public static void initVerticalXRvDecoration(Context context, XRecyclerView recyclerView, int spacing) {
        recyclerView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL,false));
        recyclerView.setPullRefreshEnabled(true);
        recyclerView.setLoadingMoreEnabled(true);
        recyclerView.setRefreshProgressStyle(ProgressStyle.SysProgress);
        recyclerView.setLoadingMoreProgressStyle(ProgressStyle.SysProgress);
        SpaceItemDecoration decoration = new SpaceItemDecoration(ScreenUtils.dip2px(context,spacing));
        recyclerView.addItemDecoration(decoration);
        recyclerView.setLimitNumberToCallLoadMore(2);
    }
    public static void initVerticalXRvDecorationNoLoadingMore(Context context, XRecyclerView recyclerView, int spacing) {
        recyclerView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL,false));
        recyclerView.setPullRefreshEnabled(true);
        recyclerView.setLoadingMoreEnabled(false);
        recyclerView.setRefreshProgressStyle(ProgressStyle.SysProgress);
        recyclerView.setLoadingMoreProgressStyle(ProgressStyle.SysProgress);
        SpaceItemDecoration decoration = new SpaceItemDecoration(spacing);
        recyclerView.addItemDecoration(decoration);
        recyclerView.setLimitNumberToCallLoadMore(2);
    }



    public static void initHorizontalXRvDecoration(Context context, XRecyclerView recyclerView, int spacing) {
        recyclerView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false));
        SpaceItemDecoration decoration = new SpaceItemDecoration(spacing);
        recyclerView.addItemDecoration(decoration);
    }






}
